﻿using System;
using System.Runtime.InteropServices;
using System.Text;

namespace MimicAPI.Window
{
    /// <summary>More information on : "http://pinvoke.net"</summary>
    static class PInvoke
    {
        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        public static extern int GetWindowTextLength(this IntPtr hWnd);
        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        public static extern int GetWindowText(this IntPtr hWnd, StringBuilder lpString, int nMaxCount);
        [DllImport("user32.dll", SetLastError = true)]
        public static extern uint GetWindowThreadProcessId(this IntPtr hWnd, out uint lpdwProcessId);

        [DllImport("user32.dll")]
        public static extern bool ShowWindow(this IntPtr hWnd, StateWindow nCmdShow);
        [DllImport("user32.dll")]
        public static extern bool IsWindow(this IntPtr hWnd);

        [DllImport("user32.dll")]
        public static extern IntPtr GetWindow(this IntPtr hWnd, GetWndCmd uCmd);
        [DllImport("user32.dll")]
        public static extern WindowStyles GetWindowLong(this IntPtr hWnd, GetWindowLongValue nIndex);

        [DllImport("psapi.dll")]
        public static extern uint GetModuleFileNameEx(this IntPtr hProcess, IntPtr hModule, [Out] StringBuilder lpBaseName,
                                                      [In] [MarshalAs(UnmanagedType.U4)] int nSize);
    }
}
